import { createSSRApp } from 'vue'
import uvUI from '@climblee/uv-ui'
import App from './App.vue'
import store from './store'
import { routeInterceptor, requestInterceptor } from './interceptors'
import 'virtual:svg-icons-register'
import 'virtual:uno.css'
// eslint-disable-next-line import/order
import Vconsole from 'vconsole'
import AsyncLoadingCustom from './components/asyncLoadingCustom/AsyncLoadingCustom.vue'

// #ifdef H5
const { VITE_NODE_ENV } = import.meta.env
console.log('VITE_NODE_ENV', VITE_NODE_ENV)

if (VITE_NODE_ENV === 'development' || VITE_NODE_ENV === 'test') {
  // eslint-disable-next-line no-new
  new Vconsole()
}
// #endif

export function createApp() {
  const app = createSSRApp(App)
  app.use(store)
  app.use(uvUI)
  app.use(routeInterceptor)
  app.use(requestInterceptor)
  app.component('AsyncLoadingCustom', AsyncLoadingCustom)
  return {
    app,
  }
}
